kopirovani souboru
Otázka od: Matejcek Petr
13. 10. 2004 17:47
DD,
poradil by pls nekdo jak v delphi zkopirovat soubor ze serveru na
lokalni HDD?
diky PM
Odpovedá: Ludo Fulop
11. 10. 2002 15:44
The CopyFile function copies an existing file to a new file.
BOOL CopyFile(
LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);
----- Original Message -----
From: "Petr Kuklik" <Petr.Kuklik@seznam.cz>
To: <delphi-l@clexpert.cz>
Sent: Friday, October 11, 2002 3:53 PM
Subject: kopirovani souboru
Dobry den,
existuje v Delphi funkce na kopirovani souboru? Neco jako
"Kopiruj(SouborA, SouborB)". At jsem hledal jak jsem hledal, tak vse
vede k tomu, aby soubor otevrel, obsah prenesl do jineho a ten jiny
ulozil.
Diky
Petr Kuklik
______________________________________________________________________
Reklama:
Nenechte si ujit novy film Woodyho Allena "Hollywood Ending" - blaznivou
komedii o tom, jak se ve tme strefit do cerneho. V kinech od 3.9.2002.
Sledujte http://www.hce.cz
Odpovedá: Bohdan Dudla
11. 10. 2002 15:51
Ahoj.
Existuje API funkce CopyFile[Ex].
With best regards,
Bohdan Dudla
Pike Electronic spol. s r.o.
Modrinova 2
300 00 Plzen
Czech Republic
tel: +420 19 72 40 738
fax: +420 19 74 31 738
gsm: +420 732 441 716
e-mail: bdudla@pikeelectronic.com
Odpovedá: Daniel Rott
11. 10. 2002 16:22
> existuje v Delphi funkce na kopirovani souboru? Neco
> jako "Kopiruj(SouborA, SouborB)". At jsem hledal jak
> jsem hledal, tak vse vede k tomu, aby soubor otevrel,
> obsah prenesl do jineho a ten jiny ulozil.
Ve Windows API jsou funkce CopyFile a CopyFileEx.
Popis Win API je i v Delphi, ale lepsi stahnout si MS
Platform SDK.
Daniel
-------------------------------------------------------
Scanning complete: NO intelligent life form in range.
Odpovedá: Andreas Bednarek
11. 10. 2002 16:34
Pro úplnost
The CopyFile function copies an existing file to a new file.
BOOL CopyFile(
LPCTSTR lpExistingFileName,
// pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);
Parameters
lpExistingFileName
Pointer to a null-terminated string that specifies the name of an existing
file.
lpNewFileName
Pointer to a null-terminated string that specifies the name of the new file.
bFailIfExists
Specifies how this operation is to proceed if a file of the same name as
that specified by lpNewFileName already exists. If this parameter is TRUE
and the new file already exists, the function fails. If this parameter is
FALSE and the new file already exists, the function overwrites the existing
file and succeeds.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error
information, call GetLastError.
Remarks
Security attributes for the existing file are not copied to the new file.
File attributes for the existing file are copied to the new file. For
example, if an existing file has the FILE_ATTRIBUTE_READONLY file attribute,
a copy created through a call to CopyFile will also have the
FILE_ATTRIBUTE_READONLY file attribute.
Windows CE: If the function succeeds, the return value is TRUE. If the
function fails, the return value is FALSE. To get extended error
information, call GetLastError.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
----- Original Message -----
From: Ludo Fulop <kexo@ynet.sk>
To: <delphi-l@clexpert.cz>
Sent: Friday, October 11, 2002 4:17 PM
Subject: Re: kopirovani souboru
> The CopyFile function copies an existing file to a new file.
>
> BOOL CopyFile(
> LPCTSTR lpExistingFileName, // pointer to name of an existing file
> LPCTSTR lpNewFileName, // pointer to filename to copy to
> BOOL bFailIfExists // flag for operation if file exists
> );
>
> ----- Original Message -----
> From: "Petr Kuklik" <Petr.Kuklik@seznam.cz>
> To: <delphi-l@clexpert.cz>
> Sent: Friday, October 11, 2002 3:53 PM
> Subject: kopirovani souboru
>
>
> Dobry den,
> existuje v Delphi funkce na kopirovani souboru? Neco jako
> "Kopiruj(SouborA, SouborB)". At jsem hledal jak jsem hledal, tak vse
> vede k tomu, aby soubor otevrel, obsah prenesl do jineho a ten jiny
> ulozil.
>
> Diky
> Petr Kuklik
>
> ______________________________________________________________________
> Reklama:
> Nenechte si ujit novy film Woodyho Allena "Hollywood Ending" - blaznivou
> komedii o tom, jak se ve tme strefit do cerneho. V kinech od 3.9.2002.
> Sledujte http://www.hce.cz
Odpovedá: bleak
12. 10. 2002 8:12
if (CopyFile(PChar(odkud),PChar(kam),False)=false) Then Begin
ShowMessage('Při kopírování souboru došlo k chybě.');
end;
----- Original Message -----
From: "Petr Kuklik" <Petr.Kuklik@seznam.cz>
existuje v Delphi funkce na kopirovani souboru? Neco jako
Odpovedá: Jirka Virt
13. 10. 2004 19:23
WINAPI
CopyFile
Jirka Virt
Odpovedá: Dalibor Faltynek
15. 10. 2004 8:25
Ahoj, ja pouzivam vetsinou toto:
procedure CopyFile(FromFname, ToFname: string);
var
FromF, ToF: file;
NumRead, NumWritten: Integer;
Buf: array[1..2048] of Char;
begin
AssignFile(FromF, FromFName);
Reset(FromF, 1); { Record size = 1 }
AssignFile(ToF, ToFName); { Open output file }
Rewrite(ToF, 1); { Record size = 1 }
try
repeat
BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
BlockWrite(ToF, Buf, NumRead, NumWritten);
until (NumRead = 0) or (NumWritten <> NumRead);
finally
CloseFile(FromF);
CloseFile(ToF);
end;{finally}
end;